LOG_I("File:\"\Product/script/src/test_msg.lua\" is running")
function  G_Sayhello(str, n)
    LOG_Debug("G_SayHello".. str ..n);
end


-- Enum值对于lua这里来说是一个number类型
LOG_D("enum LEVEL")
LOG_D("LEVEL.LOW : "..LEVEL.LOW)
LOG_D("LEVEL.MID : "..LEVEL.MID)
LOG_D("LEVEL.HIGHT : "..LEVEL.HIGHT)



--------------------------------处理分割线--------------------------------------
-- Lua想在参数中，向C++传Enum类型的暂时没有找到处理方法
-- C++ 导出有Enum类型参数的函数，参数类型是userdata，但是Lua里面传的时候，会被当做number类型，提示number与Enum类型不符合
-- 使用toLua_map.lua里面的tolua_bnd_cast函数进行强转的返回值是一个nil


--类 “MyNumber” 实践
LOG_I("test MyNumber class:")
-- 因为浮点型比较大小的时候，只能是两数之差小于某个值则为相等，
num = MyNumber:new(11,12.12,12.123456)
LOG_I("MyNumber Inited. int : "..tostring(num.m_Inumber).." float : "..tostring(num.m_Fnumber).." double : "..tostring(num.m_Dnumber))
num:SetNumber_Int(21)
num:SetNumber_Float(22.22)
num:SetNumber_Double(23.123456)
LOG_I("After MyNumber Seted. int : "..tostring(num:GetNumber_Int()).." float : "..tostring(num:GetNumber_Float()).." double : "..tostring(num:GetNumber_Double()))
-- --delete MyNumber Object
LOG_I("MyNumber Class use End, Delete object")
num:delete()
num = nil




--类 “MyString” 实践
LOG_I("new a MyString object:")
mString = MyString:new("This is toLua++ Demo ")
LOG_D("MyString Inited. char* : "..tostring (mString.m_str))
mString:SetStr("This is also a toLua++ demo")
LOG_D("MyString Seted. char* : "..mString.m_str)
LOG_D("MyString Class use End, Delete object")
mString:delete()
mString = nil


--类 “ArrayValue”实践（数组当作参数的可行性）
LOG_I("new a ArrayValue object:")
local tbFloat = {0.1,0.2,0.3}
mArrayValue = ArrayValue:new()
mArrayValue:ShowFloatArray_Ptr(tbFloat,#tbFloat)
LOG_I("ArrayValue Class use End, Delete object")
mArrayValue:delete()
mArrayValue = nil


LOG_D("One code, Much engines - Begin")
local ptr = GetGameApplication()
local piArrayValue = ptr:GetIArrayValue()
if piArrayValue == nil then
	LOG_D("piArrayValue is nil")
else
	LOG_D("piArrayValue is not nil !~~")
	tolua.type(piArrayValue)
end

--piArrayValue = toLua.cast(piArrayValue,"")
piArrayValue:ShowFloatArray_StableLength(tbFloat)
piArrayValue:ShowFloatArray_Improve(tbFloat,#tbFloat)
LOG_D("One code, Much engines - End")


--[[

--类 "MyTemplateArray" 实践(int版本)
LOG_I("new a MyTemplateArray object:")
mTemplateArray_int = MyTemplateArray_int_:new()
for i=0,10,1 do
	mTemplateArray_int:push_back(i)
end
for i=10,6,-1 do
	mTemplateArray_int:remove(i)
end
mTemplateArraySize = mTemplateArray_int:size()
LOG_D("mTemplateArraySize size is : "..mTemplateArraySize..". mTemplateArray_int's members are : ")
for i=0,5,1 do
	LOG_D("mTemplateArray_int["..i.."] = "..mTemplateArray_int[i])
end
LOG_D("MyTemplateArray Class use End, Delete object")
mTemplateArray_int:delete()
mTemplateArray_int = nil

--类 "MyTemplateArray" 实践(类类型MyString版本)
LOG_I("new a MyTemplateArray object:")
mTemplateArray_MyString = MyTemplateArray_MyString_:new()
tbMyString = {}
for i=0,10,1 do
	-- 这里使用new创建对象的话，会有内存泄露
	tbMyString[i] = MyString:new_local("this is "..i)
end
for i=0,10,1 do
	mTemplateArray_MyString:push_back(tbMyString[i])
end
for i=10,6,-1 do
	mTemplateArray_MyString:remove(i)
end
mTemplateArraySize = mTemplateArray_MyString:size()
LOG_D("mTemplateArraySize size is : "..mTemplateArraySize..". mTemplateArray_MyString's members are : ")
for i=0,5,1 do
	LOG_D("mTemplateArray_MyString["..i.."] = "..mTemplateArray_MyString[i].m_str)
end
LOG_D("MyTemplateArray Class use End, Delete object")
mTemplateArray_MyString:delete()
mTemplateArray_MyString = nil


]]

----------------------------------------------------------------------------------------------------------------------------------------------------

-- ---@class CLogic
-- CLogic = class("CLogic", nil);
-- function CLogic:ctor()
	-- print("New a object belongod MyMessage")
    -- self.message = MyMessage:new();
    -- --注册回调
    -- --self.message:RegistCallBack(self);
    -- --self.message:SetCallBackName("SendCallBack");
-- end



-- function CLogic:dtor()
    -- if self.message ~= nil then
        -- self.message:delete();
        -- self.message = nil;
    -- end
-- end




-- function CLogic:SendCallBack(msg)
    -- print("msage ".. msg .. " sned finished");
    -- return true;
-- end

-- function CLogic:SendMessaage(msg)
    -- self.message:SetMessage(msg);
	-- local str = string.format("%s\0%s\0%s\0","hello", "lua call", "back!!!");
	-- self.message:SetMessage(str);
	-- self.message:SetMessage("Hello\0lua call back\0dfgfg\0");
-- end

-- local logic = logic or CLogic:new();
-- logic:SendMessaage("Hello\0lua call back\0");
-- logic:dtor();

-- -- delete object

-- print("num is deleted,access GetNumber is invalid!")
-- print("invalidcall,result:"..num:GetNumber())

-- num:delete()
-- num2:delete()

-- -- new a MyMessage Object
-- msg = MyMessage:new()
-- print("init msg:"..msg:GetMessage())

-- local m1 = MyNumber:new(10);
-- local m2 = MyNumber:new(20);
-- local m3 = MyNumber:new(30);
-- local marr = {m1, m2, m3};
-- msg:ShowVec3(marr, 3);

-- local farry = {2.0, 3.2, 5.4,6.3,3,4,5,5,6,6,7};
-- farry = {1.0, 2.0, 3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0};
-- msg:ShowFloatArray(farry, 10);

-- local sarry = {"aaa","bbb", "ccc"};
-- msg:ShowStringArray(sarry, 3);

-- local v=MyArray_float_:new();
-- v:push_back(1.1);
-- v:push_back(2.2);
-- v:push_back(3.3);
-- msg:ShowArray(v);
-- v:delete();
-- msg:delete();

-- local str = SpaceFunction.Space_GetPath()
-- LOG(str)

-- print("-------验证：从C++获取两次对象，Lua这里会不会拷贝----------")
-- 这种情况是分两次Get，得到的是同一个对象
--vm1 = g_GetLuaVM();
--vm2 = g_GetLuaVM();
--print("vm1 is : "..tostring(vm1))
--print("vm2 is : "..tostring(vm2))
-- 下面这次是在C++函数中连续push两次，得到的是同一个对象
--vm1,vm2 = g_GetLuaVM()
--print("vm1 is : "..tostring(vm1))
--print("vm2 is : "..tostring(vm2))
-- 验证总结 ：连续push两次，Lua得到的对象是一样的，不会在表中copy！！ 

--[[
-- set message
print("msg:SetMessage('changed message')")
msg:SetMessage("changed message")
print("now msg:"..msg:GetMessage())
msg:ShowMessage()
msg:delete()
msg = nil;

num2:delete()
num2 = nil;
--]]